<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="css/style.css">
  <style>
    * {
      box-sizing: border-box;
    }

    body {
      background-color: #000;
    }

    #instance {
      width: 100%;
      height: 100%;
      margin-bottom: 100px;
    }

    #instance .demo {
      width: 100%;
      height: 100%;
      background-color: #333;
      margin: 0;
      border: none;
    }

    .btn-box {
      text-align: center;
    }

    .btn {
      margin: 20px 5px;
      font-size: 20px;
    }

    #instance2 .demo {
      margin-bottom: 0;
    }

    #instance3 {
      width: 400px;
      height: 300px;
      background-color: #fff;
      position: fixed;
      top: 20px;
      left: 20px;
    }

    #instance3 .demo {
      width: 100%;
      height: 100%;
      margin: 0;
    }
  </style>
</head>
<body>
<div id="instance">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<div id="instance2">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<div id="instance3">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<script src="js/event.js"></script>
<script>
  bind('#instance', function() {
    return new JParticles.Particle('#instance .demo', {
      color: '#5cbdaa',
      range: 2000,
      proximity: 100,
      parallax: true,
    })
  })

  bind('#instance2', function() {
    return new JParticles.Particle('#instance2 .demo', {
      parallax: true,
      parallaxStrength: 1,

      // 定义四层粒子
      parallaxLayer: [1, 3, 5, 7],
    })
  })

  // 固定定位测试
  bind('#instance3', function() {
    return new JParticles.Particle('#instance3 .demo', {
      lineShape: 'cube',
      range: 120,
      parallax: true,
      parallaxStrength: 1,
    })
  })
</script>
</body>
</html>
